package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;

import com.qidianit.mes.pojo.pro.WorkflowProcess;
import com.qidianit.mes.pro.service.WorkflowProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/18 0018 - 19:30
 */
@RestController
@RequestMapping("/workflowProcess")
@CrossOrigin
public class WorkflowProcessController {
    @Autowired
    private WorkflowProcessService workflowProcessService;
    @GetMapping("/page")
    public Result<PageInfo<WorkflowProcess>> selectByWorkflowId(Long workflowId, @RequestParam(defaultValue = "1") int page , @RequestParam(defaultValue = "10") int size){
        return workflowProcessService.selectByWorkflowId(workflowId,page,size);
    }

    @PostMapping("/add")
    public Result insertWorkflowProcess(@RequestBody WorkflowProcess workflowProcess) {
        return workflowProcessService.insertWorkflowProcess(workflowProcess);
    }
    @GetMapping("/{id}")
    public Result<WorkflowProcess> selectById(@PathVariable Long id){
        return workflowProcessService.selectById(id);
    }
    @PutMapping("/update")
    public Result updateById(@RequestBody WorkflowProcess workflowProcess){
        return workflowProcessService.updateById(workflowProcess);
    }
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return workflowProcessService.deleteById(id);
    }
    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return workflowProcessService.batchDelete(id);
    }

    @GetMapping("/list/{id}")
    public Result<ArrayList<WorkflowProcess>> selectWorkflowProcessByWorkflowId(@PathVariable Long id) {
        return workflowProcessService.selectWorkflowProcessByWorkflowId(id);
    }



}
